package com.fuyd.pms.background.qiniu;

import com.qiniu.util.Auth;

/**
 * 七牛上传策略管理器
 * Created by fuyongde on 2016/1/9.
 */
public class QiniuTokenManager {
    /**七牛AccessKey**/
    private String ak;
    /**七牛SecretKey**/
    private String sk;
    /**七牛Bucket**/
    private String bucket;

    public String getAk() {
        return ak;
    }

    public void setAk(String ak) {
        this.ak = ak;
    }

    public String getSk() {
        return sk;
    }

    public void setSk(String sk) {
        this.sk = sk;
    }

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    /**
     * 简单上传
     * @return
     */
    public String upTokenSimple(){
        Auth auth = Auth.create(ak, sk);
        return auth.uploadToken(bucket);
    }

    /**
     * 覆盖上传
     * @param key 需要覆盖的文件的key
     * @return
     */
    public String upTokenCover(String key){
        Auth auth = Auth.create(ak, sk);
        return auth.uploadToken(bucket, key);
    }

}
